<template >
  <div id="abody">
      <div class="login-container">
      <h2>智慧物联系统注册</h2>
      <form  method="post">
          <div class="form-group">
              <label for="name">用户名:</label>
              <input type="text" id="name" name="name"  v-model="name" required>
          </div>
          <div class="form-group">
              <label for="pwd">密码:</label>
              <input type="password" id="pwd" name="pwd"  v-model="pwd" required>
          </div>
          <div class="form-group">
              <label for="companyName">公司名称:</label>
              <input type="text" id="companyName" name="companyName"  v-model="companyName" required>
          </div>
          <div class="form-group">
              <label for="companyCode">编码:</label>
              <input type="text" id="companyCode" name="companyCode"  v-model="companyCode" required>
          </div>
          <div class="form-group">
              <label for="enable">启用:</label>
              <input type="text" id="enable" name="enable"  v-model="enable" required>
          </div>
          <div class="form-group">
              <label for="phone">手机号:</label>
              <input type="password" id="phone" name="phone"  v-model="phone" required>
          </div>
          <div class="form-group">
              <label for="confirm">再次输入密码:</label>
              <div class="code">
                  <input type="password" id="confirm" name="confirm" v-model="confirm" required>
                  <img src="img/code.jpg">
              </div>
          </div>
          <div class="form-group">
              <div class="code1">
                  <input type="checkbox" class="ck" name="rememberMe" id="rememberMe">
                  <span>记住我</span>
              </div>
          </div>
          <div class="form-group">
              <input type="submit" value="注册" @click.prevent="register">
          </div>
      </form>
  </div>
  </div>
</template>

<script>
import axios from 'axios';

export default {
  name: "Register",
  data(){
    return{
      name: "",
      pwd: "",
      confirm: "",
      companyName:"",
      companyCode:"",
      enable:"",
      phone:""
    }
  },
  methods: {
    register() {
      
      // 处理注册逻辑
      if (this.pwd==this.confirm) {
        this.$axios({
          url:"tenant/register",
          method:"POST",
          data:{
            name:this.name,
            pwd:this.pwd,
            companyName:this.companyName,
            companyCode:this.companyCode,
            enable:this.enable,
            phone:this.phone
          }
        }).then(res=>{
          sessionStorage.setItem("token",res.data)
          this.$router.push("/IoT");
        });
      }
    }
  }
}
</script>

<style scoped>
/* 可在此添加你的样式内容 */
#abody{
  font-family: 'Arial', sans-serif;
  background-color: #f7f7f7;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}
.login-container {
  background-color: #fff;
  padding: 40px 60px 40px 40px;
  border-radius: 5px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.login-container h2 {
  text-align: center;
  margin-bottom: 20px;
}
.form-group {
  margin-bottom: 15px;
}
.form-group label {
  display: block;
  margin-bottom: 5px;
}
.form-group input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
}
.form-group input[type="submit"] {
  width: 350px;
  background-color: #5cb85c;
  color: white;
  cursor: pointer;
}
.form-group input[type="submit"]:hover {
  background-color: #4cae4c;
}
.code{
  display: flex;
}
.code img{
  margin-left: 20px;
  width: 120px;
  height: 35px;
}

.code1{
  display: flex;
  align-items: center;
}
.code1 .ck{
  width: 20px;
  height: 20px;
  margin-right: 10px;
}
</style>